package cn.dglydrpy.study.mybatis.consumer.dao.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import cn.dglydrpy.study.mybatis.consumer.dao.UserDAO;
import cn.dglydrpy.study.mybatis.consumer.entity.User;
import cn.dglydrpy.study.mybatis.utils.SqlSessionUtils;

/**
 * @Description:
 * @author:LY_飘涯
 * @date:2021-7-3 15:51:57
 * @version:1.0
 */
public class UserDAOImpl implements UserDAO {

	@Override
	public List<User> findAll() {
		SqlSession sqlSession = SqlSessionUtils.getSqlSession();

		System.out.println("######## 进行数据库操作 ########");
		// 4.sqlSession调用方法：查询所有selectList 查询单个：selectOne 添加：insert 修改：update 删除：delete
		List<User> users = sqlSession.selectList("cn.dglydrpy.study.mybatis.consumer.mapper.UserMapper.findAll");

//	    sqlSession.commit(); //事务手动提交,写操作时需提交事务!

		sqlSession.close();
		return users;
	}

}
